package com.shr.code_interview;

import java.util.ArrayList;

public class Solution_57_1 {
    public ArrayList<ArrayList<Integer> > FindContinuousSequence(int sum) {
        int low = 1, up = 2;
        ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
        while(low <= sum / 2){
        	int tSum = 0;
        	for(int pos = low;pos<=up;pos++)
        		tSum += pos;
        	if(sum == tSum){
        		ArrayList<Integer> list = new ArrayList<>();
        		for(int pos = low;pos<=up;pos++)
        			list.add(pos);
        		lists.add(list);
        		up++;
        	}else if(tSum < sum)
        		up++ ;
        	else low++;
        }
        return lists;
    }
}
